package com.example.roomandrlivedata.viewmodel;

import android.app.Application;

import androidx.annotation.NonNull;
import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.LiveData;

import com.example.roomandrlivedata.bean.Student;
import com.example.roomandrlivedata.database.MyDatabase;

import java.util.List;

/**
 * @author: njb
 * @date: 2020/8/31 0031 23:51
 * @desc:学生ViewModel
 */
public class StudentViewModel extends AndroidViewModel {
    private MyDatabase myDatabase;
    private LiveData<List<Student>> liveDataStudent;

    public StudentViewModel(@NonNull Application application) {
        super(application);
        myDatabase = MyDatabase.getInstance(application);
        liveDataStudent = myDatabase.studentDao().getStudentList();
    }

    public LiveData<List<Student>> getLiveDataStudent() {
        return liveDataStudent;
    }
}
